﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Nightlife.Models
{
    public partial class NightlifeDB
    {

        public Checkin GetCheckin(int id)
        {
            return db.Checkins.FirstOrDefault(c => c.ID == id);
        }

        public List<Checkin> GetCheckins(User user, int fetchNum = 5)
        {
            return (from c in db.Checkins
                    join
                        u in db.Users on c.User.ID equals u.ID
                    where u.ID == user.ID
                    orderby c.Created descending
                    select c).Take(fetchNum).ToList();
        }

    }
}